
package kn.cstf2.users.Client;

import com.opensymphony.xwork2.ActionSupport;
import kn.cstf2.users.Bean.UserBean;
import kn.cstf2.users.Server.UsersServer;

/**
 *
 * @author Fernando Mares
 */
public class AddUserAction extends ActionSupport{
    private String username;
    private String pwd;
    private String email;
    private Boolean SUA;
    private String Imp;
    private String Tran;
    private String Cop;
    private Boolean TranR;
    private Boolean TranE;
    private Boolean ImpR;
    private Boolean ImpE;
    private Boolean COPR;
    private Boolean COPE;
    
    
    
    @Override
    public String execute(){
        
        UserBean userBean = new UserBean();
        UsersServer usersServer = new UsersServer();
        
        System.out.println(username);
        System.out.println(pwd);
        System.out.println(email);
        System.out.println(Imp);
        System.out.println(Tran);
        System.out.println(Cop);
//        System.out.println(TranR);
//        System.out.println(TranE);
//        System.out.println(ImpR);
//        System.out.println(ImpE);
//        System.out.println(COPR);
//        System.out.println(COPE);
        System.out.println(SUA);
        
        userBean.setEmail(email);
        userBean.setPwd(pwd);
        userBean.setUsername(username);
        userBean.setSu(SUA);
        
        if(Tran.equals("NA")){
            userBean.setTransitionAccess(false);
            userBean.setTransition(false);
        }
        if(Tran.equals("RO")){
            userBean.setTransitionAccess(true);
            userBean.setTransition(false);
        }
        if(Tran.equals("E")){
            userBean.setTransitionAccess(true);
            userBean.setTransition(true);
        }
        if(Imp.equals("NA")){
            userBean.setImplementationAccess(false);
            userBean.setImplementation(false);
        }
        if(Imp.equals("RO")){
            userBean.setImplementationAccess(true);
            userBean.setImplementation(false);
        }
        if(Imp.equals("E")){
            userBean.setImplementationAccess(true);
            userBean.setImplementation(true);
        }
        if(Cop.equals("NA")){
            userBean.setCopAccess(false);
            userBean.setCop(false);
        }
        if(Cop.equals("RO")){
            userBean.setCopAccess(true);
            userBean.setCop(false);
        }
        if(Cop.equals("E")){
            userBean.setCopAccess(true);
            userBean.setCop(true);
        }
        
        if(SUA){
            userBean.setTransitionAccess(true);
            userBean.setTransition(true);
            userBean.setImplementationAccess(true);
            userBean.setImplementation(true);
            userBean.setCopAccess(true);
            userBean.setCop(true);
        }
            
        usersServer.SaveNewUser(userBean);
        
        return "SUCCESS";
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Boolean getTranR() {
        return TranR;
    }

    public void setTranR(Boolean TranR) {
        this.TranR = TranR;
    }

    public Boolean getTranE() {
        return TranE;
    }

    public void setTranE(Boolean TranE) {
        this.TranE = TranE;
    }

    public Boolean getImpR() {
        return ImpR;
    }

    public void setImpR(Boolean ImpR) {
        this.ImpR = ImpR;
    }

    public Boolean getImpE() {
        return ImpE;
    }

    public void setImpE(Boolean ImpE) {
        this.ImpE = ImpE;
    }

    public Boolean getCOPR() {
        return COPR;
    }

    public void setCOPR(Boolean COPR) {
        this.COPR = COPR;
    }

    public Boolean getCOPE() {
        return COPE;
    }

    public void setCOPE(Boolean COPE) {
        this.COPE = COPE;
    }

    public Boolean getSUA() {
        return SUA;
    }

    public void setSUA(Boolean SUA) {
        this.SUA = SUA;
    }

    public String getImp() {
        return Imp;
    }

    public void setImp(String Imp) {
        this.Imp = Imp;
    }

    public String getTran() {
        return Tran;
    }

    public void setTran(String Tran) {
        this.Tran = Tran;
    }

    public String getCop() {
        return Cop;
    }

    public void setCop(String Cop) {
        this.Cop = Cop;
    }
    
}
